package com.example.webpractice.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.webpractice.dao.XueshengchengjiDao;
import com.example.webpractice.po.XueshengchengjiPO;
import com.example.webpractice.vo.PageVo;
import com.example.webpractice.vo.Po2Vo;
import com.example.webpractice.vo.XueshengchengjiDetailVO;
import com.example.webpractice.vo.XueshengchengjiListVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("xueshengchengjiService")
public class XueshengchengjiService {

    @Autowired
    private XueshengchengjiDao dao;

    public PageVo queryPage(int pages, int limit, QueryWrapper queryWrapper) {
        Page<XueshengchengjiPO> pagePO = dao.selectPage(new Page<>(pages, limit), queryWrapper);
        return Po2Vo.toVoPage(pagePO, XueshengchengjiListVO.class);
    }

    public XueshengchengjiDetailVO selectById(Long id) {
        XueshengchengjiPO po = dao.selectOne(new QueryWrapper<XueshengchengjiPO>().eq("id", id));
        XueshengchengjiDetailVO vo = new XueshengchengjiDetailVO();
        BeanUtils.copyProperties(po, vo);
        return vo;
    }

    public int deleteBatchIds(List list) {
        return dao.deleteByIds(list);
    }


}
